﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace ImageAppDataModels
{
    public static class Unused
    {
        //public static void GetScrollViewerInfo(this ScrollViewer scrollViewer, out double viewportWidth, out double viewportHeight, out double verticalOffset)
        //{
        //    viewportWidth = double.MaxValue;
        //    viewportHeight = double.MaxValue;
        //    verticalOffset = 0D;

        //    if (scrollViewer != null)
        //    {
        //        viewportWidth = scrollViewer.ViewportWidth;
        //        viewportHeight = scrollViewer.ViewportHeight;
        //        verticalOffset = scrollViewer.VerticalOffset;
        //    }
        //}

        //public static bool? GetIsVisibleInScroller(this DependencyObject dep, ScrollViewer scrollViewer, double viewportWidth, double viewportHeight, double verticalOffset)
        //{
        //    if (scrollViewer == null)
        //        scrollViewer = (dep as FrameworkElement).FindParent<ScrollViewer>();

        //    System.Windows.Point p = new System.Windows.Point(0, 0);

        //    if (scrollViewer != null)
        //    {
        //        try
        //        {
        //            GeneralTransform gt = (dep as Visual).TransformToVisual(scrollViewer);
        //            p = gt.Transform(new System.Windows.Point(0, 0));
        //        }
        //        catch
        //        {
        //            return null;
        //        }
        //    }

        //    double thisActualHeight = (double)dep.GetValue(Control.ActualHeightProperty);
        //    return (p.X < viewportWidth && p.Y + thisActualHeight > 0 && p.Y < viewportHeight);
        //}

        //public static List<T> GetSelected<T>(this ListBox listBox) where T : class
        //{
        //    List<T> results = new List<T>();

        //    foreach (var item in listBox.SelectedItems)
        //    {
        //        var vm = item as T;
        //        results.Add(vm);
        //    }

        //    return results;
        //}

        //public static ImageSource CreateImageSourceFromBitmapUsingSizeOptions(this Bitmap bm)
        //{
        //    if (bm != null)
        //    {
        //        BitmapSizeOptions sizeOptions = BitmapSizeOptions.FromWidthAndHeight(bm.Width, bm.Height);
        //        return bm.CreateImageSourceFromBitmap(sizeOptions);
        //    }

        //    return null;
        //}

        //public static ImageSource CreateImageSourceFromBitmap(this Bitmap bm, BitmapSizeOptions sizeOptions)
        //{
        //    if (bm != null)
        //    {
        //        IntPtr hBitmap = bm.GetHbitmap();
        //        return System.Windows.Interop.Imaging.CreateBitmapSourceFromHBitmap(hBitmap, IntPtr.Zero, Int32Rect.Empty, sizeOptions);
        //    }

        //    return null;
        //}

    }
}
